<template>
  <div class="check-page">
    <div class="muicontent">
      <div class="check-time">
        <span>日期选择:</span>
        <a-range-picker @change="onSelect"/>
        <a-button type="primary" icon="download" @click="onChange">导出Excel</a-button>
        <a-button type="primary" icon="download" @click="onAllChange" class="allexcel">导出全部</a-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'timeSearch',
  data () {
    return {
      starttime: '',
      endtime: ''
    }
  },
  methods: {
    timeFormat (num) {
      if (num < 10) { return '0' + num }
      return num
    },
    onSelect (param1, param2) {
      this.starttime = param2[0]
      this.endtime = param2[1]
    },
    onChange () {
      if (this.starttime && this.endtime) {
        window.open(`${this.baseUrl.exportExcel}?startTime=` + this.starttime + `&endTime=` + this.endtime)
      } else {
        location.reload()
      }
    },
    onAllChange () {
      window.open(`${this.baseUrl.exportAllExcel}`)
    }
  },
  watch: {}
}
</script>

<style lang="stylus" scoped>
.check-time{
    text-align: center;
    margin-top: 10%;
    span{
      font-size:.18rem;
    }
    .allexcel{
      margin-left:20px;
    }
}
</style>
